//
// Project: Disagreement in science: Missing women



clear all
version 15.1  



//
// set locals

// method of identifying female variable
local female "female_genderize"

// gender of author is known
local known_gender "female_genderize!=."




//
// Biorxiv

// call data
use "${data}/output/biorxiv_gender.dta", clear

 
// analysis
generate full_name = given_name + " " + sur_name
levelsof subject_id, local(subjects)
levelsof results_type_id, local(results)

foreach s of local subjects {
	// number of paper-author observations with known gender, all types
	sum article_id if `known_gender' & subject_id==`s'
	scalar bign`s' = r(N)
	// fraction of unique authors with gender assigned, all types
	preserve
	keep if subject_id==`s'
	collapse (firstnm) `female', by(full_name)
	tab `female', m
	local n_authors = r(N)
	tab `female'
	local n_identified = r(N)
	scalar au`s' = `n_identified'/`n_authors'
	restore
	foreach r of local results {
		// fraction of paper-author obs with known gender of given results type
		sum article_id if `known_gender' & subject_id==`s' & results_type_id==`r'
		local n = r(N)
		scalar r`s'_`r' = `n'/bign`s'
		// fraction of paper-author obs with female author
		sum `female' if subject_id==`s' & results_type_id==`r'
		scalar f`s'_`r' = r(mean)
	}
}






